package sl.cvs.service.impl;

import sl.cvs.dao.sysUser.SysUserMapper;
import sl.cvs.pojo.SysUser;
import sl.cvs.service.SysUserService;

import java.util.List;

public class SysUserServiceImpl implements SysUserService {

    private SysUserMapper sysUserMapper;

    public SysUserMapper getSysUserMapper() {
        return sysUserMapper;
    }

    public void setSysUserMapper(SysUserMapper sysUserMapper) {
        this.sysUserMapper = sysUserMapper;
    }

    @Override
    public List<SysUser> getList(SysUser sysUser) {
        try {
            return sysUserMapper.selectSysUserList(sysUser);
        }catch (RuntimeException e){
            e.printStackTrace();
            throw e;
        }
    }

    /**
     * 保存用户
     *
     * @param sysUser
     * @return
     */
    @Override
    public boolean add(SysUser sysUser) {
        boolean result = false;
        try {
            if(sysUserMapper.add(sysUser)==1) {
                return true;
                //测试事务回滚时，打开注释
                //throw new RuntimeException();
            }
        }catch (RuntimeException e){
            e.printStackTrace();
            throw e;
        }
        return result;
    }


}
